/**
 * 
 */
package interview;

import java.lang.*;

/**
 * @author lirend
 *
 */
public class Sortings {
/*
	
	static void testGrammer(){
		
		Integer i= new Integer("10");
		if (i.toString().equals( i.toString()))
		System.out.println("Equal");
		else
		System.out.println("Not Equal");
	}

	static void testInsertSort(){
		
		SortingHelper sortingHelper = new SortingHelper();
		int[] originalArray=new int[]{9,2,13,66,1,343,88,6};  
		for(int i : originalArray){
			System.out.print(i+", ");
		
		}
		System.out.println("");
		int[] sortResult = sortingHelper.insertSort(originalArray);
		for(int i : sortResult){
			System.out.print(i+", ");
		
		}
		System.out.println("");
		
		try{
			System.in.read();
		}
		catch(Exception ex)
		{
			//throw new Exception(ex.toString());
		}
	}

	static void testFebonacci()
	{
		for(int i=0;i<100;i++){
			int overflowSign = 1;
			overflowSign = Fibonacci.returnFibonacciN(i);
			if(overflowSign<0){
				System.out.println("");	
				System.out.println("Overflow at "+i);	
				System.out.println("");	
				break;
			}
			System.out.print(overflowSign+", ");
			if(i % 10 == 0){
				System.out.println("");
			
			}
			if(overflowSign<0){
				
			}
		}
		

		
	}

	 protected void testMergeSort(){
		int[] originalArray=new int[]{9,2,13,66,1,343,88,6};  
		for(int i : originalArray){
			System.out.print(i+", ");
		
		}
		System.out.println("");
		mergeSort(originalArray);
		for(int i : originalArray){
			System.out.print(i+", ");
		
		}
		System.out.println("");
		
		try{
			System.in.read();
		}
		catch(Exception ex)
		{
			//throw new Exception(ex.toString());
		}
	
	}
	
	@Override
	public int[] insertSort(int[] originalArray) {

		int tmp=-1;
		if(originalArray.length<=1)
		{
			return originalArray;
		
		}
		for(int i=1;i<originalArray.length;i++){
			tmp=originalArray[i];
			for(int j=i-1;j>=0;j--)
			{
				if(originalArray[j]>tmp)
				{
					originalArray[j+1]=originalArray[j];
					originalArray[j]=tmp;
				}
				else{
					break;
				}
			}
		
		}
		return originalArray;
	}

	@Override
	public int[] mergeSort(int[] originalArray) {
		// TODO Auto-generated method stub
		
		mergeSort(originalArray, 0, originalArray.length-1);
		return null;
	}
	
	private void mergeSort(int[] array, int start, int end)
	{
		if(end>start){
			int mid = (end+start)/2;
			mergeSort(array, start, mid);
			mergeSort(array, mid+1, end);
			merge(array, start, mid, end);
		}
	}
	private void merge(int[] originalArray, int p, int q, int r){
		int[] left = new int[q-p+1+1];
		int[] right = new int[r-q+1];
		for(int i=0;i<left.length-1;i++){
			left[i] = originalArray[p+i];
		}
		left[left.length-1]=Integer.MAX_VALUE;
		for(int i=0;i<right.length-1;i++){
			right[i] = originalArray[q+1+i];
		}
		right[right.length-1]=Integer.MAX_VALUE;
		int leftIndx = 0;
		int rightIndx = 0;
		for(int i=p;i<=r;i++){
			if(left[leftIndx]<right[rightIndx]){
				originalArray[i]=left[leftIndx];
				leftIndx++;
			}else{
				originalArray[i]=right[rightIndx];
				rightIndx++;
			
			}
		}
	
	}

	public static int returnFibonacciN(int n)
	{
		int a = 1;
		int b=1;
		
		int i=1;
		while(i<=n)
		{
			int previousB=b;
			b=a+b;
			a=previousB;
			i++;
		}
		
		return b;
	}
	
	*/
}
